package com.homeparking.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.homeparking.common.annotation.Log;
import com.homeparking.common.core.controller.BaseController;
import com.homeparking.common.core.domain.AjaxResult;
import com.homeparking.common.enums.BusinessType;
import com.homeparking.manage.domain.ImgSwiper;
import com.homeparking.manage.service.IImgSwiperService;
import com.homeparking.common.utils.poi.ExcelUtil;
import com.homeparking.common.core.page.TableDataInfo;

/**
 * 页面轮播图Controller
 * 
 * @author liuyangyang
 * @date 2025-07-12
 */
@RestController
@RequestMapping("/manage/imgswiper")
public class ImgSwiperController extends BaseController
{
    @Autowired
    private IImgSwiperService imgSwiperService;
    /**
     * 查询页面轮播图列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ImgSwiper imgSwiper)
    {
        startPage();
        List<ImgSwiper> list = imgSwiperService.selectImgSwiperList(imgSwiper);
        return getDataTable(list);
    }

    /**
     * 导出页面轮播图列表
     */
    @PreAuthorize("@ss.hasPermi('manage:imgswiper:export')")
    @Log(title = "页面轮播图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ImgSwiper imgSwiper)
    {
        List<ImgSwiper> list = imgSwiperService.selectImgSwiperList(imgSwiper);
        ExcelUtil<ImgSwiper> util = new ExcelUtil<ImgSwiper>(ImgSwiper.class);
        util.exportExcel(response, list, "页面轮播图数据");
    }

    /**
     * 获取页面轮播图详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:imgswiper:query')")
    @GetMapping(value = "/{imgId}")
    public AjaxResult getInfo(@PathVariable("imgId") Long imgId)
    {
        return success(imgSwiperService.selectImgSwiperByImgId(imgId));
    }

    /**
     * 新增页面轮播图
     */
    @PreAuthorize("@ss.hasPermi('manage:imgswiper:add')")
    @Log(title = "页面轮播图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImgSwiper imgSwiper)
    {
        return toAjax(imgSwiperService.insertImgSwiper(imgSwiper));
    }

    /**
     * 修改页面轮播图
     */
    @PreAuthorize("@ss.hasPermi('manage:imgswiper:edit')")
    @Log(title = "页面轮播图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImgSwiper imgSwiper)
    {
        return toAjax(imgSwiperService.updateImgSwiper(imgSwiper));
    }

    /**
     * 删除页面轮播图
     */
    @PreAuthorize("@ss.hasPermi('manage:imgswiper:remove')")
    @Log(title = "页面轮播图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imgIds}")
    public AjaxResult remove(@PathVariable Long[] imgIds)
    {
        return toAjax(imgSwiperService.deleteImgSwiperByImgIds(imgIds));
    }
}
